﻿Option Explicit On 
Option Strict On

Imports System.Windows.Forms

''' -----------------------------------------------------------------------------
''' Project	 : IPCommon
''' Class	 : Core.IPCommon.CControlFormat
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' Đây là lớp tạo Format chuẩn của IP cho các Control
''' </summary>
''' <remarks>
''' Được sử dụng tại tất cả các form của IP. Chủ yếu là trong chỗ method format_controls() được gọi
''' ngay khi form khởi tạo
''' </remarks>
''' <history>
''' 	[csung]	2/22/2005	Created
''' </history>
''' -----------------------------------------------------------------------------
Public Interface IControlerControl
    Function CanUseControl( _
                ByVal ip_strFormName As String _
                , ByVal ip_strControlName As String _
                , ByVal ip_strControlType As String) As Boolean
End Interface
Public Class CControlFormat


#Region "Constants declaration"
    Private Const C_FormFontSize As Double = 8.0!
    Private Const C_FormHeightFontSize As Double = 10.0!
#End Region


#Region "Private services"

    Private Shared Function getRegularFont() As System.Drawing.Font
        Return New System.Drawing.Font(m_str_font_name, C_FormFontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    End Function

    Private Shared Function getRegularForeColor() As System.Drawing.Color
        Return System.Drawing.Color.Navy
    End Function

    Private Shared Function getRegularBackColor() As System.Drawing.Color
        Return System.Drawing.Color.AliceBlue
    End Function

    Private Shared Function getBoldFont() As System.Drawing.Font
        Return New System.Drawing.Font(m_str_font_name, C_FormFontSize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    End Function
    Private Shared Function getBoldHeightFont() As System.Drawing.Font
        Return New System.Drawing.Font(m_str_font_name, C_FormHeightFontSize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    End Function
#End Region

#Region "Public interface"
    Public Shared Sub setFormStyle(ByVal i_form As Form _
    , ByVal i_objControlerControl As IControlerControl _
    , Optional ByVal i_form_style As IPFormStyle = IPFormStyle.DialogForm)
        Try
            AddHandler i_form.KeyDown, AddressOf i_form_KeyDown

            Dim v_Control As System.Windows.Forms.Control
            i_form.KeyPreview = True
            With i_form
                '.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
                .BackColor = getRegularBackColor()
                .Font = getRegularFont()
                .ForeColor = getRegularForeColor()
                Select Case i_form_style
                    Case IPFormStyle.DialogForm
                        .FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
                        .MaximizeBox = False
                        .MinimizeBox = False
                        .StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
                        .ShowInTaskbar = False
                    Case IPFormStyle.DockableTopForm
                        .FormBorderStyle = FormBorderStyle.Sizable
                        .MaximizeBox = True
                        .MinimizeBox = True
                        .StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
                        .ShowInTaskbar = False
                    Case Else

                End Select

                '.ResumeLayout(False)
                'Tund sửa ngày 11/06/2008
                formatControlInForms(i_form.Name, i_objControlerControl, i_form)
               
            End With
        Catch exp As Exception
            MessageBox.Show(exp.Message, i_form.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Stop)
        Finally

        End Try
    End Sub


    Public Shared Sub setDefaultFontName(ByVal i_str_fone_name As String)
        m_str_font_name = i_str_fone_name
    End Sub
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    '''  Dùng để set các property của Form ngoại trừ frmMain
    ''' </summary>
    ''' <param name="i_form">form cần phải format</param>
    ''' <param name="i_form_style">formstyle như thế nào, hiện nay đang sử dụng hai loại chính dialog form và 
    ''' dockable form. Hai giá trị của IPFormStyle
    ''' </param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setFormStyle(ByVal i_form As Form, Optional ByVal i_form_style As IPFormStyle = IPFormStyle.DialogForm)
        Try
            AddHandler i_form.KeyDown, AddressOf i_form_KeyDown

            Dim v_Control As System.Windows.Forms.Control
            i_form.KeyPreview = True
            With i_form
                '.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
                .BackColor = getRegularBackColor()
                .Font = getRegularFont()
                .ForeColor = getRegularForeColor()
                Select Case i_form_style
                    Case IPFormStyle.DialogForm
                        .FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
                        .MaximizeBox = False
                        .MinimizeBox = False
                        .StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
                        .ShowInTaskbar = False
                    Case IPFormStyle.DockableTopForm
                        .FormBorderStyle = FormBorderStyle.Sizable
                        .MaximizeBox = True
                        .MinimizeBox = True
                        .StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
                        .ShowInTaskbar = False
                    Case Else

                End Select

                '.ResumeLayout(False)
                'TA sửa ngày 29/12/2003
                For Each v_Control In .Controls
                    If TypeOf v_Control Is Label Then
                        v_Control.Font = getRegularFont()
                        v_Control.ForeColor = getRegularForeColor()
                        v_Control.BackColor = getRegularBackColor()
                    ElseIf TypeOf v_Control Is TextBox Then
                        v_Control.Font = getRegularFont()
                        v_Control.ForeColor = getRegularForeColor()
                    ElseIf TypeOf v_Control Is GroupBox Then
                        v_Control.Font = getRegularFont()
                        v_Control.ForeColor = getRegularForeColor()
                        v_Control.BackColor = getRegularBackColor()
                    ElseIf TypeOf v_Control Is ComboBox Then
                        v_Control.Font = getRegularFont()
                        v_Control.ForeColor = getRegularForeColor()
                    ElseIf TypeOf v_Control Is CheckBox Then
                        v_Control.Font = getRegularFont()
                        v_Control.ForeColor = getRegularForeColor()
                    ElseIf TypeOf v_Control Is Button Then
                        v_Control.Font = getRegularFont()
                        v_Control.ForeColor = getRegularForeColor()
                    End If
                Next
            End With
        Catch exp As Exception
            MessageBox.Show(exp.Message, i_form.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Stop)
        Finally

        End Try
    End Sub
    Private Shared Sub i_form_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
        If e.KeyCode = Keys.F1 Then
            System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\HELP\BVInvest_User's_Guide.chm")
        End If

    End Sub
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Set format cho các C1Flexgrid dùng trong ứng dụng
    ''' </summary>
    ''' <param name="i_fg">C1FlexGrid classis </param>
    ''' <remarks>
    ''' Đây chỉ sử dụng cho phổ biết, vì IP chỉ dùng C1FlexGrid chứ không dùng C1FlexGridClassis
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setC1FlexFormat(ByVal i_fg As C1.Win.C1FlexGrid.Classic.C1FlexGridClassic)
        '***************************************************
        ' Dùng để set các property của C1FlexGridClassic
        '***************************************************
        With i_fg

            .AllowBigSelection = False
            .AllowUserResizing = C1.Win.C1FlexGrid.Classic.AllowUserResizeSettings.flexResizeColumns
            .BackColor = System.Drawing.SystemColors.Window
            .BackColorAlternate = System.Drawing.SystemColors.Window
            .BackColorBkg = System.Drawing.SystemColors.AppWorkspace
            .BackColorFixed = System.Drawing.SystemColors.Control
            .BackColorSel = System.Drawing.SystemColors.Highlight
            .Editable = C1.Win.C1FlexGrid.Classic.EditableSettings.flexEDKbdMouse
            .ExplorerBar = C1.Win.C1FlexGrid.Classic.ExplorerBarSettings.flexExSortShowAndMove
            .ExtendLastCol = True
            .FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.Solid
            .ForeColor = System.Drawing.SystemColors.WindowText
            .ForeColorFixed = System.Drawing.SystemColors.Highlight
            .ForeColorSel = System.Drawing.SystemColors.HighlightText
            .GridColor = System.Drawing.SystemColors.Control
            .GridColorFixed = System.Drawing.SystemColors.ControlDark
            .MergeCells = C1.Win.C1FlexGrid.Classic.MergeSettings.flexMergeOutline
            .OutlineBar = C1.Win.C1FlexGrid.Classic.OutlineBarSettings.flexOutlineBarSimple
            .SheetBorder = System.Drawing.SystemColors.WindowText
            .TreeColor = System.Drawing.Color.DarkGray
            .Tree.Style = C1.Win.C1FlexGrid.TreeStyleFlags.Complete
            .SubtotalPosition = C1.Win.C1FlexGrid.SubtotalPositionEnum.AboveData
            .CausesValidation = True
            .AutoSizeMode = C1.Win.C1FlexGrid.Classic.AutoSizeSettings.flexAutoSizeColWidth
            .Styles.Fixed.Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Bold)
            .Styles.Fixed.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter
            .Styles.Fixed.ForeColor = System.Drawing.SystemColors.Highlight
            .Styles.Alternate.BackColor = System.Drawing.Color.FromArgb(CType(241, Byte), CType(252, Byte), CType(218, Byte))
            .Styles.EmptyArea.Border.Style = C1.Win.C1FlexGrid.BorderStyleEnum.None
            .SelectionMode = C1.Win.C1FlexGrid.Classic.SelModeSettings.flexSelectionFree
            .Cursor = System.Windows.Forms.Cursors.Hand

        End With
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Dùng để set format của các fixed rows
    ''' </summary>
    ''' <param name="i_fg"></param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setC1FixedRowsFormat(ByVal i_fg As C1.Win.C1FlexGrid.C1FlexGrid)
        '***************************************************
        ' Dùng để set các property của C1FlexGrid
        '***************************************************
        With i_fg


            .AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
            .AutoSearch = C1.Win.C1FlexGrid.AutoSearchEnum.None
            .BackColor = System.Drawing.SystemColors.Window
            .ExtendLastCol = True
            .FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.Solid
            .ForeColor = System.Drawing.SystemColors.WindowText
            .Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Regular)
            .Styles.Fixed.Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Bold)
            .Styles.Fixed.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter
            .Styles.Fixed.ForeColor = System.Drawing.SystemColors.Highlight
            .Styles.EmptyArea.BackColor = .BackColor
            .Styles.EmptyArea.Border.Style = C1.Win.C1FlexGrid.BorderStyleEnum.None
            .SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell

        End With
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Chỉnh format cho các C1FlexGrid
    ''' </summary>
    ''' <param name="i_fg">c1flexgrid  cần format</param>
    ''' <param name="i_gridstyle">Là grid style, Kiểu của nó là C1GridStyle. Có hai loại Editable và ViewAndSearch</param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setC1FlexFormat(ByVal i_fg As C1.Win.C1FlexGrid.C1FlexGrid, _
                                     Optional ByVal i_gridstyle As C1GridStyle = C1GridStyle.GridViewAndSearch)
        '***************************************************
        ' Dùng để set các property của C1FlexGrid
        '***************************************************
        With i_fg
            Select Case i_gridstyle
                Case C1GridStyle.GridInplaceEditing
                    '.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
                    .AutoSearch = C1.Win.C1FlexGrid.AutoSearchEnum.None
                    .BackColor = System.Drawing.SystemColors.Window
                    '.Dock = System.Windows.Forms.DockStyle.Fill
                    .ExtendLastCol = True
                    .FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.Solid
                    .ForeColor = System.Drawing.SystemColors.WindowText
                    .Tree.Style = C1.Win.C1FlexGrid.TreeStyleFlags.Complete
                    .Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Regular)
                    .Styles.Fixed.Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Bold)
                    .Styles.Fixed.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter
                    .Styles.Fixed.ForeColor = System.Drawing.SystemColors.Highlight
                    .Styles.Alternate.BackColor = System.Drawing.Color.FromArgb(CType(241, Byte), CType(252, Byte), CType(218, Byte))
                    .Styles.EmptyArea.BackColor = .BackColor
                    .Styles.EmptyArea.Border.Style = C1.Win.C1FlexGrid.BorderStyleEnum.None
                    .AllowEditing = True
                    .AllowAddNew = True
                    .KeyActionEnter = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcross
                    .KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcrossOut
                    .Cursor = System.Windows.Forms.Cursors.Hand
                    .AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
                Case C1GridStyle.GridViewAndSearch
                    '.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Free
                    .AutoSearch = C1.Win.C1FlexGrid.AutoSearchEnum.FromTop
                    .BackColor = System.Drawing.SystemColors.Window
                    '.Dock = System.Windows.Forms.DockStyle.Fill
                    .ExtendLastCol = True
                    .FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.Solid
                    .ForeColor = System.Drawing.SystemColors.WindowText
                    .Tree.Style = C1.Win.C1FlexGrid.TreeStyleFlags.Complete
                    .Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Regular)
                    .Styles.Fixed.Font = New System.Drawing.Font(m_str_font_name, C_FormFontSize, Drawing.FontStyle.Bold)
                    .Styles.Fixed.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter
                    .Styles.Fixed.ForeColor = System.Drawing.SystemColors.Highlight
                    .Styles.Alternate.BackColor = System.Drawing.Color.FromArgb(CType(241, Byte), CType(252, Byte), CType(218, Byte))
                    .Styles.EmptyArea.BackColor = .BackColor
                    .Styles.EmptyArea.Border.Style = C1.Win.C1FlexGrid.BorderStyleEnum.None
                    .AllowAddNew = False
                    .AllowEditing = False
                    .Cursor = System.Windows.Forms.Cursors.Hand
                    .AllowDragging = C1.Win.C1FlexGrid.AllowDraggingEnum.None
            End Select

        End With
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' SET format cho các treeview control
    ''' </summary>
    ''' <param name="i_Treeview"></param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setTreeview(ByVal i_Treeview As TreeView)

        With i_Treeview
            .BackColor = System.Drawing.SystemColors.Info
            .Font = getRegularFont()
            .ForeColor = getRegularForeColor()
        End With
    End Sub


    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Set format cho các button
    ''' </summary>
    ''' <param name="i_Button"></param>
    ''' <param name="i_ButtonStyle"></param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setButtonStyle(ByVal i_Button As System.Windows.Forms.Button, _
                                     ByVal i_ButtonStyle As ButtonStyle)
        i_Button.Font = getRegularFont()
        i_Button.Height = 25
        i_Button.Width = 130
        i_Button.BackColor = System.Drawing.Color.LightYellow
        i_Button.ForeColor = getRegularForeColor()

        Select Case i_ButtonStyle
            Case ButtonStyle.CancelButtonStyle
                i_Button.Text = "Hủy bỏ (ESC)"
            Case ButtonStyle.ExitButtonStyle
                i_Button.Text = "Thoát (ESC)"
            Case ButtonStyle.OkButtonStyle
                i_Button.Text = "Chấp nhận (Alt+C)"
            Case ButtonStyle.FreeFunctionButtonStyle

            Case ButtonStyle.LongFunctionButtonStyle
                i_Button.Width = 200
            Case ButtonStyle.MediumFunctionButtonStyle
                i_Button.Width = 160
            Case ButtonStyle.SmallFunctionButtonStyle
                i_Button.Width = 130
        End Select
    End Sub


    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Set format cho các label trong form. Rất quan trọng. Lưu ý là nếu bạn không set thì các label của bạn sẽ
    ''' không bao giờ thẳng hàng. Ngay cả khi TextAlignment của bạn đã chỉnh tốt.
    ''' </summary>
    ''' <param name="i_lbl">label cần phải format</param>
    ''' <param name="i_labelStyle">Kiểu label. Bình thường nhất là PromptLabel</param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setLabelStyle(ByVal i_lbl As Label, _
                                    ByVal i_labelStyle As LabelStyle)
        Dim v_Font As System.Drawing.Font = getRegularFont()
        Dim v_ForeColor As System.Drawing.Color = getRegularForeColor()
        Select Case i_labelStyle
            Case LabelStyle.Title_Info
                v_Font = getBoldFont()
                v_ForeColor = System.Drawing.Color.Blue
            Case LabelStyle.HighLight_Info
                v_Font = getBoldFont()
                v_ForeColor = System.Drawing.Color.Blue
            Case LabelStyle.Additional_Info

            Case LabelStyle.Prompt_Info
                i_lbl.Text = i_lbl.Text & vbCrLf
                i_lbl.TextAlign = Drawing.ContentAlignment.MiddleRight
            Case LabelStyle.BoldHighLight_Info
                v_Font = getBoldHeightFont()
                v_ForeColor = System.Drawing.Color.Blue
        End Select
        i_lbl.Font = v_Font
        i_lbl.ForeColor = v_ForeColor
    End Sub
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Set format cho các LinkLabel trong form. Rất quan trọng.
    ''' </summary>
    ''' <param name="i_lbl">LinkLabel cần phải format</param>
    ''' <param name="i_labelStyle">Kiểu LinkLabel. Bình thường nhất là PromptLabel</param>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[csung]	2/22/2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Shared Sub setLinkLabelStyle(ByVal i_lbl As LinkLabel, _
                                    ByVal i_LinkLabelStyle As LinkLabelStyle)
        Dim v_Font As System.Drawing.Font = getRegularFont()
        Dim v_ForeColor As System.Drawing.Color = getRegularForeColor()
        Select Case i_LinkLabelStyle
            Case LinkLabelStyle.Title_Info
                i_lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
                i_lbl.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline
                i_lbl.LinkColor = System.Drawing.Color.Blue
                i_lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
            Case LinkLabelStyle.HighLight_Info
                v_Font = getBoldFont()
                v_ForeColor = System.Drawing.Color.Blue
                i_lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
                i_lbl.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline
                i_lbl.LinkColor = System.Drawing.Color.Blue
                i_lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
            Case LinkLabelStyle.Additional_Info

            Case LinkLabelStyle.Prompt_Info
                i_lbl.Text = i_lbl.Text & vbCrLf
                i_lbl.TextAlign = Drawing.ContentAlignment.MiddleRight
                i_lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
                i_lbl.LinkBehavior = System.Windows.Forms.LinkBehavior.NeverUnderline
                i_lbl.LinkColor = System.Drawing.Color.Blue
                i_lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        End Select
        i_lbl.Font = v_Font
        i_lbl.ForeColor = v_ForeColor
    End Sub

    Public Shared Sub set_all_label_style_as_promt(ByVal i_frm As Form)
        Dim v_container As New ControlContainer(i_frm)
        set_all_label_style_as_promt_recursive(v_container)
    End Sub


#End Region

#Region "Privates"


    Private Shared Sub set_all_label_style_as_promt_recursive(ByVal i_container As ControlContainer)
        Dim v_ctl As Control
        For Each v_ctl In i_container.getControls
            If v_ctl.GetType.ToString = "System.Windows.Forms.Label" Then
                Dim v_lbl As Label = CType(v_ctl, Label)
                setLabelStyle(v_lbl, LabelStyle.Prompt_Info)
            ElseIf v_ctl.GetType.ToString = "System.Windows.Forms.Panel" Then
                Dim v_pnl As Panel = CType(v_ctl, Panel)
                Dim v_pnl_container As New ControlContainer(v_pnl)
                set_all_label_style_as_promt_recursive(v_pnl_container)
            ElseIf v_ctl.GetType.ToString = "System.Windows.Forms.GroupBox" Then
                Dim v_grp As GroupBox = CType(v_ctl, GroupBox)
                Dim v_grp_container As New ControlContainer(v_grp)
                set_all_label_style_as_promt_recursive(v_grp_container)
            End If

        Next
    End Sub

    Private Shared Sub formatControlInForms( _
    ByVal ip_str_form_name As String _
    , ByVal i_objControlerControl As IControlerControl _
    , ByVal ip_control As System.Windows.Forms.Control)

        If (ip_control.ToString().IndexOf("SIS.Controls.Button.SiSButton") >= 0) Then
            If (i_objControlerControl.CanUseControl(ip_str_form_name, ip_control.Name, "") = False) Then
                ip_control.Visible = False
                ip_control.Enabled = False
            End If
        End If
        If TypeOf ip_control Is Label Then
            ip_control.Font = getRegularFont()
            ip_control.ForeColor = getRegularForeColor()
            ip_control.BackColor = getRegularBackColor()
        ElseIf TypeOf ip_control Is TextBox Then
            ip_control.Font = getRegularFont()
            ip_control.ForeColor = getRegularForeColor()
        ElseIf TypeOf ip_control Is GroupBox Then
            ip_control.Font = getRegularFont()
            ip_control.ForeColor = getRegularForeColor()
            ip_control.BackColor = getRegularBackColor()
        ElseIf TypeOf ip_control Is ComboBox Then
            ip_control.Font = getRegularFont()
            ip_control.ForeColor = getRegularForeColor()
        ElseIf TypeOf ip_control Is CheckBox Then
            ip_control.Font = getRegularFont()
            ip_control.ForeColor = getRegularForeColor()
            'ElseIf TypeOf ip_control Is Button Then
            '    ip_control.Font = getRegularFont()
            '    ip_control.ForeColor = getRegularForeColor()
            '    If (i_objControlerControl.CanUseControl(ip_str_form_name, ip_control.Name, "") = False) Then
            '        ip_control.Visible = False
            '        ip_control.Enabled = False
            '    End If
        End If
        Dim v_control As System.Windows.Forms.Control
        For Each v_control In ip_control.Controls
            formatControlInForms(ip_str_form_name, i_objControlerControl, v_control)
        Next

    End Sub
#End Region
#Region "Members"
    Private Shared m_str_font_name As String
#End Region

End Class

''' -----------------------------------------------------------------------------
''' Project	 : IPCommon
''' Class	 : Core.IPCommon.ControlContainer
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' Chỉ để giúp loop qua tất cả các control trên form
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' 	[csung]	3/8/2005	Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class ControlContainer
    Private m_frm As Form
    Private m_pnl As Panel
    Private m_grp As GroupBox

    Public Sub New(ByVal i_form As Form)
        m_frm = i_form
    End Sub

    Public Sub New(ByVal i_groupbox As GroupBox)
        m_grp = i_groupbox
    End Sub

    Public Sub New(ByVal i_panel As Panel)
        m_pnl = i_panel
    End Sub

    Function getControls() As Control.ControlCollection
        If Not (m_frm Is Nothing) Then
            Return m_frm.Controls
        ElseIf Not (m_grp Is Nothing) Then
            Return m_grp.Controls
        Else
            Return m_pnl.Controls
        End If
    End Function
End Class


Public Enum IPFormStyle
    DockableTopForm
    DialogForm
    MessageForm
    FlashForm
End Enum

Public Enum ButtonStyle

    ExitButtonStyle
    CancelButtonStyle
    OkButtonStyle

    SmallFunctionButtonStyle
    MediumFunctionButtonStyle
    LongFunctionButtonStyle
    FreeFunctionButtonStyle
End Enum

Public Enum LabelStyle
    Title_Info
    HighLight_Info
    BoldHighLight_Info
    Additional_Info
    Prompt_Info

End Enum

Public Enum LinkLabelStyle
    Title_Info
    HighLight_Info
    Additional_Info
    Prompt_Info
End Enum

''' -----------------------------------------------------------------------------
''' <summary>
''' Kiểu của c1 flex grid. Có hai loại chính
''' <list type="bullet">
''' <item> in-place-edit</item>
''' <item> readonly</item>
''' </list>
''' </summary>
''' <remarks>
''' Khác nhau nhiều nhất là ở AllowAddNew, AllowEdit được enable cho loại in-place-edit. Còn AutoSearch được enable
''' cho loại readonly
''' </remarks>
''' <history>
''' 	[csung]	2/22/2005	Created
''' </history>
''' -----------------------------------------------------------------------------
Public Enum C1GridStyle
    GridViewAndSearch = 1
    GridInplaceEditing = 2
End Enum
